cmake_minimum_required(VERSION 3.25)
project(CODES_IN_BOOK
        VERSION 2025.3.1
        LANGUAGES C)

set(CMAKE_C_STANDARD 11)

set(MY_BIN_PATH ${PROJECT_SOURCE_DIR}/output)
set(RUNTIME_OUTPUT_DIRECTORY   ${MY_BIN_PATH})
set(RUNTIME_OUTPUT_DIRECTORY_DEBUG   ${MY_BIN_PATH}/DEBUG)
set(RUNTIME_OUTPUT_DIRECTORY_RELEASE   ${MY_BIN_PATH}/RELEASE)

add_subdirectory(chap02_lexer build/chap02)
add_subdirectory(chap03_rdp build/chap03)
add_subdirectory(chap04_rdp build/chap04)

find_package(FLEX REQUIRED)
if (FLEX_FOUND)
    message(STATUS  "Flex is found, subdir chap03_lexdemo will be built.")
    add_subdirectory(chap03_lexdemo build/lexdemo)
else ()
    message(WARNING "Flex is not found, chap03_lexdemo will not be built.")
endif ()
